package com.acmuno.greenchili;

import java.util.InputMismatchException;
import java.util.Scanner;
import org.json.me.JSONStringer;

public class APITestDriver {

	static JSONStringer js;
	static URLQuery query;

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		
		int a = 0;
		do{															//TOP LEVEL MENU
			System.out.println("Linger Query Menu: ");
			System.out.println("1. Add Linger Message");
			System.out.println("2. List Linger Messages");
			System.out.print("Selection  (-1 to terminate): ");
			try{
			a = in.nextInt();
			}catch(InputMismatchException e){
				System.out.print("Must enter an integer. Please reselect: ");
				a = in.nextInt();
			}
			if((a>2) || (a<-1))
				System.out.println("Please choose an acceptable parameter.\n");
		}while((a>2) || (a<-1));
			switch(a){
				case 1 : LingerMessage lm = new LingerMessage();			//add message to server.
						lm.setMessage();
						query = new URLQuery();
						query.addJSON(lm.toString());
					break;
			
				case 2: query = new URLQuery();								//list messages from server.
						query.listJSON();
				
					break;
			
				case -1 : System.out.println("Connection terminated.");
					break;				
		}
	}

	
}
